package com.cwj;


import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.info.GraphLayout;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author chenwujie
 * @date 2020-12-09 15:14
 */
public class TestObjectMemory {
    public static void main(String[] args) throws IOException {
//        Object o = new Object();
//        boolean b = true;
//        Data data = new Data();
//        Data[] booleans = new Data[10];
//        booleans[0] = new Data();
//        booleans[1] = new Data();
//        System.out.println(ClassLayout.parseInstance(booleans).toPrintable());
//        System.out.println(ClassLayout.parseInstance(o).toPrintable());
//        System.out.println(ClassLayout.parseInstance(b).toPrintable());
//        System.out.println(ClassLayout.parseInstance(booleans).toPrintable());
//        System.out.println(ClassLayout.parseInstance(booleans[0]).toPrintable());
//        System.out.println(GraphLayout.parseInstance(o).toPrintable());
        Map<Long, Long> map = new HashMap<>();
        System.out.println(ClassLayout.parseInstance(map).toPrintable());

//        map.put("100002", "张明");
        map.put(1111L, 1111L);
        System.out.println(GraphLayout.parseInstance(map).toPrintable());

        System.out.println();
        Set<Long> strings = map.keySet();
        System.out.println(GraphLayout.parseInstance(map).toPrintable());

        Set<Map.Entry<Long, Long>> entries = map.entrySet();
        System.out.println(GraphLayout.parseInstance(map).toPrintable());

        char[] arr = new char[10];
        System.out.println(ClassLayout.parseInstance(arr).toPrintable());
//        GraphLayout.parseInstance(map).toImage("map.png");
        // e5 01 00 f8 (11100101 00000001 00000000 11111000) (-134217243)
//        System.out.println(0b11111000_00000000_00000001_11100101);
    }
    static class Data{
        private boolean b1;
        private byte by1;
//        private short st;
//        private char c;
//        private int i;
//        private float f;
        private long l;
        private double d;
//        private long l1;
//        private long p1, p2, p3, p4, p5, p6, p7;
//        private Integer i1;
//        private boolean b;
//        private byte bt;
//        private char c;
//        private short s;
//        private float f;
//        private int i;
//        private long l;
//        private double d;
//        private boolean[] bArray;


    }


}
